/**
 * Created by dukes on 2015/12/4.
 */
//module game{
    class BlackListItemRender extends eui.ItemRenderer{
        public constructor(){
            super();
            this.skinName = "pet.BlackListItemRenderSkin";
        }

        public dataChanged(){
            super.dataChanged();
            this.lab_name.text = LimitStringLen(this.data.blockUserName);
            if( Model.me.platform != PlatformEnum.QQBROWSER){
                this.img_head.source = (this.data.figureurl && this.data.figureurl != "") ? this.data.figureurl : RES.getRes("default_head_0") ;
            }else{
                this.img_head.source = RES.getRes("default_head_"+(this.data.blockUserId%5));
            }
        }

        private onRemove(evt:egret.TouchEvent){
            window["__unblocks"](this.data.blockUserId);
        }

        private lab_name:eui.Label;
        private img_head:eui.Image;
        private img_remove:eui.Image;
        public partAdded(name:string, instance:any){
            super.partAdded(name, instance);
            if( name == "lab_name"){
                this.lab_name = instance;
            }else if( name == "img_head"){
                this.img_head = instance;
            }else if( name == "img_remove"){
                this.img_remove = instance;
                this.img_remove.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onRemove, this);
            }
        }
    }
//}